<!DOCTYPE html>
<html>

<head>
  <title>Quarkus - Azure Functions (Serverless) with RESTEasy, Undertow, or Vert.x Web</title>
  <script id="adobe_dtm" src="https://www.redhat.com/dtm.js" type="text/javascript"></script>
  <script src="/assets/javascript/highlight.pack.js" type="text/javascript"></script>
  <META HTTP-EQUIV='Content-Security-Policy' CONTENT="default-src 'none'; script-src 'self' 'unsafe-eval' 'sha256-ANpuoVzuSex6VhqpYgsG25OHWVA1I+F6aGU04LoI+5s=' 'sha256-ipy9P/3rZZW06mTLAR0EnXvxSNcnfSDPLDuh3kzbB1w=' js.bizographics.com https://www.redhat.com assets.adobedtm.com jsonip.com https://ajax.googleapis.com https://www.googletagmanager.com https://www.google-analytics.com https://use.fontawesome.com; style-src 'self' https://fonts.googleapis.com https://use.fontawesome.com; img-src 'self' *; media-src 'self' ; frame-src https://www.googletagmanager.com https://www.youtube.com; frame-ancestors 'none'; base-uri 'none'; object-src 'none'; form-action 'none'; font-src 'self' https://use.fontawesome.com https://fonts.gstatic.com;">
  <META HTTP-EQUIV='X-Frame-Options' CONTENT="DENY">
  <META HTTP-EQUIV='X-XSS-Protection' CONTENT="1; mode=block">
  <META HTTP-EQUIV='X-Content-Type-Options' CONTENT="nosniff">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="Quarkus: Supersonic Subatomic Java">
  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:site" content="@QuarkusIO"> 
  <meta name="twitter:creator" content="@QuarkusIO">
  <meta property="og:url" content="https://quarkus.io/guides/azure-functions-http" />
  <meta property="og:title" content="Quarkus - Azure Functions (Serverless) with RESTEasy, Undertow, or Vert.x Web" />
  <meta property="og:description" content="Quarkus: Supersonic Subatomic Java" />
  <meta property="og:image" content="/assets/images/quarkus_card.png" />
  <link rel="canonical" href="https://quarkus.io/guides/azure-functions-http">
  <link rel="shortcut icon" type="image/png" href="/favicon.ico" >
  <link rel="stylesheet" href="https://quarkus.io/guides/stylesheet/config.css" />
  <link rel="stylesheet" href="/assets/css/main.css" />
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
  <link rel="alternate" type="application/rss+xml"  href="https://quarkus.io/feed.xml" title="Quarkus">
  <script src="https://quarkus.io/assets/javascript/goan.js" type="text/javascript"></script>
  <script src="https://quarkus.io/assets/javascript/hl.js" type="text/javascript"></script>
</head>

<body class="guides">
  <!-- Google Tag Manager (noscript) -->
  <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NJWS5L"
  height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
  <!-- End Google Tag Manager (noscript) -->

  <div class="nav-wrapper">
  <div class="grid-wrapper">
    <div class="width-12-12">
      <input type="checkbox" id="checkbox" />
      <nav id="main-nav" class="main-nav">
  <div class="container">
    <div class="logo-wrapper">
      
        <a href="/"><img src="/assets/images/quarkus_logo_horizontal_rgb_600px_reverse.png" class="project-logo" title="Quarkus"></a>
      
    </div>
    <label class="nav-toggle" for="checkbox">
      <i class="fa fa-bars"></i>
    </label>
    <div id="menu" class="menu">
      <span>
        <a href="/get-started/" class="">Get Started</a>
      </span>
      <span>
        <a href="/guides/" class="active">Guides</a>
      </span>
      <span>
        <a href="/community/" class="">Community</a>
      </span>
      <span>
        <a href="/support/" class="">Support</a>
      </span>
      <span>
        <a href="/blog/" class="">Blog</a>
      </span>
      <span>
        <a href="https://code.quarkus.io" class="button-cta secondary white">Start Coding</a>
      </span>
    </div>
  </div>
      </nav>
    </div>
  </div>
</div>

  <div class="content">
    <div class="guide">
  <div class="width-12-12">
    <h1 class="text-caps">Quarkus - Azure Functions (Serverless) with RESTEasy, Undertow, or Vert.x Web</h1>
    <div class="hide-mobile toc"><ul class="sectlevel1">
<li><a href="#prerequisites">Prerequisites</a></li>
<li><a href="#solution">Solution</a></li>
<li><a href="#creating-the-maven-deployment-project">Creating the Maven Deployment Project</a></li>
<li><a href="#login-to-azure">Login to Azure</a></li>
<li><a href="#build-and-deploy-to-azure">Build and Deploy to Azure</a></li>
<li><a href="#extension-maven-dependencies">Extension maven dependencies</a></li>
<li><a href="#azure-deployment-descriptors">Azure Deployment Descriptors</a></li>
<li><a href="#config-azure-paths">Configuring Root Paths</a></li>
</ul></div>
    <div>
      <div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>The <code>quarkus-azure-functions-http</code> extension allows you to write microservices with RESTEasy (JAX-RS),
Undertow (servlet), Vert.x Web, or <a href="funqy-http">Funqy HTTP</a> and make these microservices deployable to the Azure Functions runtime.</p>
</div>
<div class="paragraph">
<p>One azure function deployment can represent any number of JAX-RS, servlet, Vert.x Web, or <a href="funqy-http">Funqy HTTP</a> endpoints.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>This technology is considered preview.</p>
</div>
<div class="paragraph">
<p>In <em>preview</em>, backward compatibility and presence in the ecosystem is not guaranteed.
Specific improvements might require to change configuration or APIs and plans to become <em>stable</em> are under way.
Feedback is welcome on our <a href="https://groups.google.com/d/forum/quarkus-dev">mailing list</a> or as issues in our <a href="https://github.com/quarkusio/quarkus/issues">GitHub issue tracker</a>.</p>
</div>
<div class="paragraph">
<p>For a full list of possible extension statuses, check our <a href="https://quarkus.io/faq/#extension-status">FAQ entry</a>.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="prerequisites"><a class="anchor" href="#prerequisites"></a>Prerequisites</h2>
<div class="sectionbody">
<div class="paragraph">
<p>To complete this guide, you need:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>less than 15 minutes</p>
</li>
<li>
<p>JDK 1.8 (Azure requires JDK 1.8)</p>
</li>
<li>
<p>Apache Maven 3.6.2+</p>
</li>
<li>
<p><a href="https://azure.microsoft.com">An Azure Account</a>.  Free accounts work.</p>
</li>
<li>
<p><a href="https://docs.microsoft.com/en-us/cli/azure/install-azure-cli">Azure CLI Installed</a></p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="solution"><a class="anchor" href="#solution"></a>Solution</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This guide walks you through running a Maven Archetype to generate a sample project that contains three http endpoints
written with JAX-RS APIs, Servlet APIs, Vert.x Web, or <a href="funqy-http">Funqy HTTP</a> APIs.  After building, you will then be able to deploy
to Azure.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="creating-the-maven-deployment-project"><a class="anchor" href="#creating-the-maven-deployment-project"></a>Creating the Maven Deployment Project</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Create the azure maven project for your Quarkus application using our Maven Archetype.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">mvn archetype:generate \
    -DarchetypeGroupId=io.quarkus \
    -DarchetypeArtifactId=quarkus-azure-functions-http-archetype \
    -DarchetypeVersion=1.7.0.Final</code></pre>
</div>
</div>
<div class="paragraph">
<p>Running this command will run maven in interactive mode and it will ask you to fill in some build properties:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>groupId</code> - The maven groupId of this generated project.  Type in <code>org.acme</code>.</p>
</li>
<li>
<p><code>artifactId</code> - The maven artifactId of this generated project. Type in <code>quarkus-demo</code></p>
</li>
<li>
<p><code>version</code> - Version of this generated project.</p>
</li>
<li>
<p><code>package</code> - defaults to <code>groupId</code></p>
</li>
<li>
<p><code>appName</code> - Use the default value.  This is the application name in Azure.  It must be a unique subdomain name under <code>*.azurewebsites.net</code>. Otherwise deploying to Azure will fail.</p>
</li>
<li>
<p><code>appRegion</code> - Defaults to <code>westus</code>.  Dependent on your azure region.</p>
</li>
<li>
<p><code>function</code> - Use the default which is <code>quarkus</code>.  Name of your azure function. Can be anything you want.</p>
</li>
<li>
<p><code>resourceGroup</code> - Use the default value.  Any value is fine though.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The values above are defined as properties in the generated <code>pom.xml</code> file.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="login-to-azure"><a class="anchor" href="#login-to-azure"></a>Login to Azure</h2>
<div class="sectionbody">
<div class="paragraph">
<p>If you don&#8217;t login to Azure you won&#8217;t be able to deploy.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">az login</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="build-and-deploy-to-azure"><a class="anchor" href="#build-and-deploy-to-azure"></a>Build and Deploy to Azure</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The <code>pom.xml</code> you generated in the previous step pulls in the <code>azure-functions-maven-plugin</code>.  Running maven install
generates config files and a staging directory required by the <code>azure-functions-maven-plugin</code>.  Here&#8217;s
how to execute it.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">./mvnw clean install azure-functions:deploy</code></pre>
</div>
</div>
<div class="paragraph">
<p>If you haven&#8217;t already created your function up at azure, the will build an uber-jar, package it, create the function
at Azure, and deploy it.</p>
</div>
<div class="paragraph">
<p>If deployment is a success, the azure plugin will tell you the base URL to access your function.</p>
</div>
<div class="paragraph">
<p>i.e.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">Successfully deployed the artifact to https://quarkus-demo-123451234.azurewebsites.net</code></pre>
</div>
</div>
<div class="paragraph">
<p>The URL to access the service would be</p>
</div>
<div class="paragraph">
<p><a href="https://{appName}.azurewebsites.net/api/hello" class="bare">https://{appName}.azurewebsites.net/api/hello</a>
<a href="https://{appName}.azurewebsites.net/api/servlet/hello" class="bare">https://{appName}.azurewebsites.net/api/servlet/hello</a>
<a href="https://{appName}.azurewebsites.net/api/vertx/hello" class="bare">https://{appName}.azurewebsites.net/api/vertx/hello</a>
<a href="https://{appName}.azurewebsites.net/api/funqyHello" class="bare">https://{appName}.azurewebsites.net/api/funqyHello</a></p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="extension-maven-dependencies"><a class="anchor" href="#extension-maven-dependencies"></a>Extension maven dependencies</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The sample project includes the RESTEasy, Undertow, Vert.x Web, <a href="funqy-http">Funqy HTTP</a> extensions.  If you are only using one of those
APIs (i.e. jax-rs only), respectively remove the maven dependency <code>quarkus-resteasy</code>, <code>quarkus-undertow</code>, <code>quarkus-funqy-http</code>, and/or
<code>quarkus-vertx-web</code>.</p>
</div>
<div class="paragraph">
<p>You must include the <code>quarkus-azure-functions-http</code> extension as this is a generic bridge between the Azure Functions
runtime and the HTTP framework you are writing your microservices in.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="azure-deployment-descriptors"><a class="anchor" href="#azure-deployment-descriptors"></a>Azure Deployment Descriptors</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Templates for Azure Functions deployment descriptors (<code>host.json</code>, <code>function.json</code>) are within
the <code>azure-config</code> directory.  Edit them as you need to.  Rerun the build when you are ready.</p>
</div>
<div class="paragraph">
<p><strong>NOTE</strong>: If you change the <code>function.json</code> <code>path</code> attribute or if you add a <code>routePrefix</code>,
your jax-rs endpoints won&#8217;t route correctly.  See <a href="#config-azure-paths">Configuring Root Paths</a> for more information.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="config-azure-paths"><a class="anchor" href="#config-azure-paths"></a>Configuring Root Paths</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The default route prefix for an Azure Function is <code>/api</code>.  All of your JAX-RS, Servlet, Vert.x Web, and <a href="funqy-http">Funqy HTTP</a> endpoints must
explicitly take this into account.  In the generated project this is handled by the
<code>quarkus.http.root-path</code> switch in <code>application.properties</code></p>
</div>
<div class="paragraph">
<p>If you modify the <code>path</code> or add a <code>routePrefix</code> within the <code>azure-config/function.json</code>
deployment descriptor, your code or configuration must also reflect any prefixes you specify for your path.</p>
</div>
</div>
</div>
    </div>
  </div>
</div>

  </div>

  <div class="content project-footer">
  <div class="footer-section">
    <div class="logo-wrapper">
      <a href="/"><img src="/assets/images/quarkus_logo_horizontal_rgb_reverse.svg" class="project-logo" title="Quarkus"></a>
    </div>
  </div>
  <div class="grid-wrapper">
    <p class="grid__item width-3-12">Quarkus is open. All dependencies of this project are available under the <a href='https://www.apache.org/licenses/LICENSE-2.0' target='_blank'>Apache Software License 2.0</a> or compatible license.<br /><br />This website was built with <a href='https://jekyllrb.com/' target='_blank'>Jekyll</a>, is hosted on <a href='https://pages.github.com/' target='_blank'>Github Pages</a> and is completely open source. If you want to make it better, <a href='https://github.com/quarkusio/quarkusio.github.io' target='_blank'>fork the website</a> and show us what you’ve got.</p>

    
      <div class="width-1-12 project-links">
        <span>Navigation</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="/">Home</a></li>
          
            <li><a href="/guides">Guides</a></li>
          
            <li><a href="/community/#contributing">Contribute</a></li>
          
            <li><a href="/faq">FAQ</a></li>
          
            <li><a href="/get-started">Get Started</a></li>
          
        </ul>
      </div>
    
      <div class="width-1-12 project-links">
        <span>Contribute</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="https://twitter.com/quarkusio">Follow us</a></li>
          
            <li><a href="https://github.com/quarkusio">GitHub</a></li>
          
            <li><a href="/security">Security&nbsp;policy</a></li>
          
        </ul>
      </div>
    
      <div class="width-1-12 project-links">
        <span>Get Help</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="https://groups.google.com/forum/#!forum/quarkus-dev">Forums</a></li>
          
            <li><a href="https://quarkusio.zulipchat.com">Chatroom</a></li>
          
        </ul>
      </div>
    

    
      <div class="width-3-12 more-links">
        <span>Quarkus is made of community projects</span>
        <ul class="footer-links">
          
            <li><a href="https://vertx.io/" target="_blank">Eclipse Vert.x</a></li>
          
            <li><a href="https://microprofile.io" target="_blank">Eclipse MicroProfile</a></li>
          
            <li><a href="https://hibernate.org" target="_blank">Hibernate</a></li>
          
            <li><a href="https://netty.io" target="_blank">Netty</a></li>
          
            <li><a href="https://resteasy.github.io" target="_blank">RESTEasy</a></li>
          
            <li><a href="https://camel.apache.org" target="_blank">Apache Camel</a></li>
          
            <li><a href="https://code.quarkus.io/" target="_blank">And many more...</a></li>
          
        </ul>
      </div>
    
  </div>
</div>
  <div class="content redhat-footer">
  <div class="grid-wrapper">
    <span class="licence">
      <i class="fab fa-creative-commons"></i><i class="fab fa-creative-commons-by"></i> <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank">CC by 3.0</a> | <a href="https://www.redhat.com/en/about/privacy-policy">Privacy Policy</a>
    </span>
    <span class="redhat">
      Sponsored by
    </span>
    <span class="redhat-logo">
      <a href="https://www.redhat.com/" target="_blank"><img src="/assets/images/redhat_reversed.svg"></a>
    </span>
  </div>
</div>


  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" integrity="sha384-8gBf6Y4YYq7Jx97PIqmTwLPin4hxIzQw5aDmUg/DDhul9fFpbbLcLh3nTIIDJKhx" crossorigin="anonymous"></script>
  <script type="text/javascript" src="/assets/javascript/mobile-nav.js"></script>
  <script type="text/javascript" src="/assets/javascript/scroll-down.js"></script>
  <script src="/assets/javascript/satellite.js" type="text/javascript"></script>
  <script src="https://quarkus.io/guides/javascript/config.js" type="text/javascript"></script>
  <script src="/assets/javascript/search-filter.js" type="text/javascript"></script>
  <script src="/assets/javascript/back-to-top.js" type="text/javascript"></script>
</body>

</html>
